Skip to content

Conversation

lamATnginx
Copy link
Collaborator

Proposed changes

Closes https://github.com/nginxinc/docs-platform/issues/424

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • I have updated any relevant documentation (README.md and CHANGELOG.md)

@lamATnginx lamATnginx added the enhancement New feature or request label Mar 27, 2025
@lamATnginx lamATnginx self-assigned this Mar 27, 2025
@lamATnginx lamATnginx requested a review from a team as a code owner March 27, 2025 20:29
@nginx-jack
Copy link
Collaborator

This is working fine locally 👍 .

Few things to tweak:
It should be possible to do this with just CSS. The cases in the if statements, can all be inferred purely from the browser size. The exception being the search page, but since that's a different page in hugo, you could set a different class explicitly for that page maybe.

Refactoring to pure css aside, the resize event triggers every pixel change. It shouldn't impact performance when it's only changing classes, but a small debounce function to wrap it in might be no harm, like

function debounce(func, wait = 200) {
  let timeout;
  return function (...args) {
    clearTimeout(timeout);
    timeout = setTimeout(() => func.apply(this, args), wait);
  };
}

Then wrap what's in you current event listener closure in a function, and call it like window.addEventListener('resize', debounce(updateSearchBarVisibility, 200));

This is working as is, but I'd like to at least add the debounce in before merging. If we do end up adding more logic to resize, it'll start to chug when people resize.
We can come back to refactoring as CSS later, if that sounds alright?

@lamATnginx lamATnginx force-pushed the feat/coveo-wider-support branch from c1e5bf3 to 33e2e9f Compare March 28, 2025 17:42
@lamATnginx lamATnginx merged commit 02b3c7b into main Mar 31, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants